/**
 * 配置单例
 * @author xialeistudio
 * @date 2016/5/9 0009
 */
'use strict';
const prodConfig = require('../config.json')
		, devConfig = require('../config-dev.json')
		, loggerManager = require('./logger');
class Config {
	constructor() {
		this.isDev = true;
		//读取命令行
		let args = process.argv.splice(2);
		args.forEach((item)=> {
			if (item.indexOf('--dev') !== -1) {
				this.isDev = true;
			}
		});
		//读取环境变量
		this.isDev = this.isDev || process.env.NODE_ENV === 'dev';
		const mode = this.isDev ? 'development' : 'production';
		loggerManager.info(`[Config] sharedManager initialized mode ${mode}`);
	}

	/**
	 * 加载配置
	 * @returns {*}
	 */
	loadConfig() {
		return this.isDev ? devConfig : prodConfig;
	}
}
module.exports = new Config();